{% extends "base.html" %}

{% block title %}编辑账目 - 记账系统{% endblock %}

{% block content %}
    <h2>编辑账目 (ID: {{ expense.id }})</h2>
    <form method="post" action="{{ url_for('edit_expense', id=expense.id) }}">
        <div class="form-group">
            <label for="date">日期 (YYYY/M/D):</label>
            {# expense.date 可能已经是 YYYY/M/D 格式，如果不是，确保 app.py 中已转换 #}
            <input type="text" id="date" name="date" value="{{ expense.date }}" required>
        </div>
        <div class="form-group">
            <label for="amount">金额:</label>
            <input type="number" id="amount" name="amount" step="0.01" value="{{ expense.amount }}" required>
        </div>
        <div class="form-group">
            <label for="main_category">大分类:</label>
            <input type="text" id="main_category" name="main_category" value="{{ expense.main_category }}" required>
        </div>
        <div class="form-group">
            <label for="sub_category">二级分类 (可选):</label>
            <input type="text" id="sub_category" name="sub_category" value="{{ expense.sub_category if expense.sub_category is not none else '' }}">
        </div>
        <div class="form-group">
            <label for="payment_method">支付方式 (可选):</label>
            <input type="text" id="payment_method" name="payment_method" value="{{ expense.payment_method if expense.payment_method is not none else '' }}">
        </div>
        <div class="form-group">
            <label for="notes">备注 (可选):</label>
            <textarea id="notes" name="notes">{{ expense.notes if expense.notes is not none else '' }}</textarea>
        </div>
        <p>
            <button type="submit">保存更改</button>
            <a href="{{ url_for('index') }}" class="button-link button-secondary" style="margin-left: 10px;">取消</a>
        </p>
    </form>
{% endblock %}
